package net.awpspace.mobile.management.book;

import java.util.Vector;

import javax.microedition.midlet.MIDlet;

import net.awpspace.mobile.form.BaseForm;
import net.awpspace.mobile.global.Global;

import com.sun.lwuit.List;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;

/**
 * View list books
 * 
 * @author Diep
 */
public class ViewList extends BaseForm {

	private Vector books;
	private List list;

	public ViewList(MIDlet app, BaseForm parent, Vector books) {
		super(app, parent);
		setTitle(Global.BOOK_LIST);
		setLayout(new BoxLayout(BoxLayout.Y_AXIS));
		this.books = books;

		list = new List();
		list.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent evt) {
				new ViewBook(ViewList.this.app, ViewList.this,
						(BookModel) ViewList.this.books.elementAt(list
								.getSelectedIndex())).show();
			}
		});
		for (int i = 0; i < books.size(); ++i) {
			list.addItem(((BookModel) books.elementAt(i)).getName());
		}
		addComponent(list);
	}

	protected void processCommand(ActionEvent e) {
	}
}
